home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / TURB_VIS / TVISION / HELLO.PAS < prev    next >
Pascal/Delphi Source File  |  1990-10-23  |  3KB  |  104 lines

  1. {************************************************}
  2. {                                                }
  3. {   Turbo Pascal 6.0                             }
  4. {   Demo program from the Turbo Vision Guide     }
  5. {                                                }
  6. {   Copyright (c) 1990 by Borland International  }
  7. {                                                }
  8. {************************************************}
  9.  
  10. program Hello;
  11.  
  12. uses Objects, Drivers, Views, Menus, Dialogs, App;
  13.  
  14. const
  15.   GreetThemCmd = 100;
  16.  
  17. type
  18.   PHelloApp = ^THelloApp;
  19.   THelloApp = object(TApplication)
  20.     procedure GreetingBox;
  21.     procedure HandleEvent(var Event: TEvent); virtual;
  22.     procedure InitMenuBar; virtual;
  23.     procedure InitStatusLine; virtual;
  24.   end;
  25.  
  26. { THelloApp }
  27. procedure THelloApp.GreetingBox;
  28. var
  29.   R: TRect;
  30.   D: PDialog;
  31.   C: Word;
  32. begin
  33.   { Create a dialog }
  34.   R.Assign(25, 5, 55, 16);
  35.   D := New(PDialog, Init(R, 'Hello, World!'));
  36.  
  37.   { Create and insert controls into the dialog}
  38.   R.Assign(3, 5, 15, 6);
  39.   D^.Insert(New(PStaticText, Init(R, 'How are you?')));
  40.  
  41.   R.Assign(16, 2, 28, 4);
  42.   D^.Insert(New(PButton, Init(R, 'Terrific', cmCancel, bfNormal)));
  43.  
  44.   R.Assign(16, 4, 28, 6);
  45.   D^.Insert(New(PButton, Init(R, 'Ok', cmCancel, bfNormal)));
  46.  
  47.   R.Assign(16, 6, 28, 8);
  48.   D^.Insert(New(PButton, Init(R, 'Lousy', cmCancel, bfNormal)));
  49.  
  50.   R.Assign(16, 8, 28, 10);
  51.   D^.Insert(  New(PButton, Init(R, 'Cancel', cmCancel, bfNormal)));
  52.  
  53.   { Execute the modal dialog }
  54.   C := DeskTop^.ExecView(D);
  55. end;
  56.  
  57. procedure THelloApp.HandleEvent(var Event: TEvent);
  58. begin
  59.   TApplication.HandleEvent(Event);
  60.   if Event.What = evCommand then
  61.   begin
  62.     case Event.Command of
  63.       GreetThemCmd: GreetingBox;
  64.     else
  65.       Exit;
  66.     end;
  67.     ClearEvent(Event);
  68.   end;
  69. end;
  70.  
  71. procedure THelloApp.InitMenuBar;
  72. var
  73.   R: TRect;
  74. begin
  75.   GetExtent(R);
  76.   R.B.Y := R.A.Y + 1;
  77.   MenuBar := New(PMenuBar, Init(R, NewMenu(
  78.     NewSubMenu('~H~ello', hcNoContext, NewMenu(
  79.       NewItem('~G~reeting...','', 0, GreetThemCmd, hcNoContext,
  80.       NewLine(
  81.       NewItem('E~x~it', 'Alt-X', kbAltX, cmQuit, hcNoContext, nil)))), nil))));
  82. end;
  83.  
  84. procedure THelloApp.InitStatusLine;
  85. var
  86.   R: TRect;
  87. begin
  88.   GetExtent(R);
  89.   R.A.Y := R.B.Y-1;
  90.   StatusLine := New(PStatusLine, Init(R,
  91.     NewStatusDef(0, $FFFF,
  92.       NewStatusKey('', kbF10, cmMenu,
  93.       NewStatusKey('~Alt-X~ Exit', kbAltX, cmQuit, nil)), nil)));
  94. end;
  95.  
  96. var
  97.   HelloWorld: THelloApp;
  98.  
  99. begin
  100.   HelloWorld.Init;
  101.   HelloWorld.Run;
  102.   HelloWorld.Done;
  103. end.
  104.